﻿Public Class ucUsuarios
    Private _ehParaSelecionarTodos As Boolean = True
    Private _permiteDigitacao As Boolean = False
    Private _id_tipo_usuario As Integer

    Public Property PERMITEDIGITACAO As Boolean
        Get
            Return _permiteDigitacao
        End Get
        Set(value As Boolean)
            _permiteDigitacao = value
        End Set
    End Property

    Public Property ID_TIPO_USUARIO() As Integer
        Get
            Return _id_tipo_usuario
        End Get
        Set(value As Integer)
            _id_tipo_usuario = value
        End Set
    End Property

    Public Property getPeritoSelecionado() As Integer
        Get
            Return cmbPerito.SelectedValue
        End Get
        Set(ByVal value As Integer)
            cmbPerito.SelectedValue = value
        End Set

    End Property

    Public Property ehSelecionarTodos() As Boolean
        Get
            Return _ehParaSelecionarTodos

        End Get
        Set(ByVal value As Boolean)
            _ehParaSelecionarTodos = value
        End Set

    End Property


    Public Property ativaAutocomplete() As Boolean

        Get
            Return cmbPerito.AutoCompleteMode

        End Get

        Set(ByVal value As Boolean)

            cmbPerito.AutoCompleteMode = AutoCompleteMode.SuggestAppend
            cmbPerito.AutoCompleteSource = AutoCompleteSource.ListItems
        End Set

    End Property


    Public Property getNomePeritoSelecionado() As String

        Get
            Return cmbPerito.SelectedText

        End Get

        Set(ByVal value As String)

            cmbPerito.SelectedText = value
        End Set

    End Property

    Public Property getMaspPeritoSelecionado() As String

        Get
            Return cmbPerito.SelectedValue

        End Get

        Set(ByVal value As String)
            cmbPerito.SelectedValue = value

        End Set

    End Property

    Private Sub populaDados()
        Try
            Dim usuario As New usuariosDAO
            Dim oTable As New DataTable
            oTable = usuario.GETUSUARIOS(_id_tipo_usuario)
            cmbPerito.DataSource = oTable
            cmbPerito.ValueMember = "MASP"
            cmbPerito.DisplayMember = "NOME"
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub


    Private Sub ucPerito_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not DesignMode Then

            populaDados()
        End If

    End Sub

    Private Sub cmbPerito_KeyPress(sender As Object, e As KeyPressEventArgs) Handles cmbPerito.KeyPress

        If PERMITEDIGITACAO Then
            e.Handled = False
        Else
            e.Handled = True
        End If

    End Sub
End Class
